from manimlib import *
from numpy import flip, insert

LV,QL,QH,JH='#75cfb8','#bbdfc8','#f0e5d8','#ffc478'

class p1(ThreeDScene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        hour,minute,seconds=4,50,0
        circle=Circle(3).set_stroke(width=20)
        p=circle.get_top()+DOWN*0.7
        for i in range(12):
            self.add(
                Line(UP*0.5,ORIGIN).set_stroke(width=13).next_to(p,UP,buff=0).rotate_about_origin(PI/6*i),
                # Tex(str(i+1)).scale(1.5).move_to(Dot(ORIGIN).shift(UP*3.5).rotate_about_origin(2*PI-(i+1)*PI/6))
                )
        for i in range(60):
            self.add(
                Line(UP*0.3,ORIGIN).next_to(p,UP,buff=0).rotate_about_origin(PI/30*i)
            )
        arrow_h=Arrow(ORIGIN,p,buff=0).set_color(LV)
        arrow_m,arrow_s=arrow_h.copy(),arrow_h.copy()
        angle_h=(hour+(minute+seconds/60)/60)*PI/6
        angle_m=(minute+seconds/60)*DEGREES*6
        angle_s=seconds*DEGREES
        #
        arrow_h.rotate_about_origin(PI*2-angle_h)
        arrow_m.rotate_about_origin(PI*2-angle_m)
        arrow_s.rotate_about_origin(PI*2-angle_s)
        self.add(circle,arrow_h,arrow_m,arrow_s)
        self.set_camera_orientation(theta=PI*1.3)
        self.wait()

class p2(ThreeDScene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        hour,minute,seconds=4,50,0
        circle=Circle(3).set_stroke(width=20)
        p=circle.get_top()+DOWN*0.7
        for i in range(12):
            self.add(
                Line(UP*0.5,ORIGIN).set_stroke(width=13).next_to(p,UP,buff=0).rotate_about_origin(PI/6*i),
                # Tex(str(i+1)).scale(1.5).move_to(Dot(ORIGIN).shift(UP*3.5).rotate_about_origin(2*PI-(i+1)*PI/6))
                )
        for i in range(60):
            self.add(
                Line(UP*0.3,ORIGIN).next_to(p,UP,buff=0).rotate_about_origin(PI/30*i)
            )
        arrow_h=Arrow(ORIGIN,p,buff=0).set_color(LV)
        arrow_m,arrow_s=arrow_h.copy(),arrow_h.copy()
        angle_h=(hour+(minute+seconds/60)/60)*PI/6
        angle_m=(minute+seconds/60)*DEGREES*6
        angle_s=seconds*DEGREES
        #
        arrow_h.rotate_about_origin(PI*2-angle_h)
        arrow_m.rotate_about_origin(PI*2-angle_m)
        arrow_s.rotate_about_origin(PI*2-angle_s)
        self.add(circle,arrow_h,arrow_m,arrow_s)
        self.set_camera_orientation(theta=PI*1.3)
        self.add(
            Tex('A').shift(LEFT).move_to([-1.3,0.5,0]).rotate(-0.2*PI),
            Tex('B').move_to([1,-1,0]).rotate(-0.2*PI),
            Tex('C').move_to([0.3,1.5,0]).rotate(-0.2*PI)
        )
        self.wait()

class p3(ThreeDScene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        hour,minute,seconds=4,50,0
        circle=Circle(3).set_stroke(width=20)
        p=circle.get_top()+DOWN*0.7
        for i in range(12):
            self.add(
                Line(UP*0.5,ORIGIN).set_stroke(width=13).next_to(p,UP,buff=0).rotate_about_origin(PI/6*i),
                )
        for i in range(60):
            self.add(
                Line(UP*0.3,ORIGIN).next_to(p,UP,buff=0).rotate_about_origin(PI/30*i)
            )
        arrow_h=Arrow(ORIGIN,p,buff=0).set_color(LV)
        arrow_m,arrow_s=arrow_h.copy(),arrow_h.copy()
        angle_h=(hour+(minute+seconds/60)/60)*PI/6
        angle_m=(minute+seconds/60)*DEGREES*6
        angle_s=seconds*DEGREES
        #
        arrow_h.rotate_about_origin(PI*2-angle_h)
        arrow_m.rotate_about_origin(PI*2-angle_m)
        arrow_s.rotate_about_origin(PI*2-angle_s)
        self.add(circle,arrow_h,arrow_m,arrow_s)
        self.set_camera_orientation(theta=PI*1.3)
        self.add(
            Tex('A').shift(LEFT).move_to([-1.3,0.5,0]).rotate(-0.2*PI),
            Tex('B').move_to([1,-1,0]).rotate(-0.2*PI),
            Tex('C').move_to([0.3,1.5,0]).rotate(-0.2*PI)
        )
        for i in range(12):
            self.add(
                Tex(str(i+1)).scale(1.5).move_to(Dot(ORIGIN).shift(UP*3.5).rotate_about_origin(2*PI-(i-1)*PI/6)).rotate(-0.2*PI)
                )
        self.wait()

class p4(ThreeDScene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        hour,minute,seconds=4,50,0
        circle=Circle(3).set_stroke(width=20)
        p=circle.get_top()+DOWN*0.7
        for i in range(12):
            self.add(
                Line(UP*0.5,ORIGIN).set_stroke(width=13).next_to(p,UP,buff=0).rotate_about_origin(PI/6*i),
                Tex(str(i+1)).scale(1.5).move_to(Dot(ORIGIN).shift(UP*3.5).rotate_about_origin(2*PI-(i+1)*PI/6))
                )
        for i in range(60):
            self.add(
                Line(UP*0.3,ORIGIN).next_to(p,UP,buff=0).rotate_about_origin(PI/30*i)
            )
        arrow_h=Arrow(ORIGIN,p,buff=0).set_color(LV)
        arrow_m,arrow_s=arrow_h.copy(),arrow_h.copy()
        angle_h=(hour+(minute+seconds/60)/60)*PI/6
        angle_m=(minute+seconds/60)*DEGREES*6
        angle_s=seconds*DEGREES
        #
        arrow_h.rotate_about_origin(PI*2-angle_h)
        arrow_m.rotate_about_origin(PI*2-angle_m)
        arrow_s.rotate_about_origin(PI*2-angle_s)
        self.add(circle,arrow_h,arrow_m,arrow_s)
        # self.set_camera_orientation(theta=PI*1.3)
        self.add(
            Tex('A').shift(LEFT).move_to([-1.3,0.5,0]),
            Tex('B').move_to([1,-1,0]),
            Tex('C').move_to([0.3,1.5,0])
        )
        self.wait()